About 900 letters

About 5 minutes

#staticmethod

Description: Encapsulate a method as a static method. Refer to the classmethod function.

def staticmethod(fn): ''' Encapsulate a method as a static method :param fn: The method to encapsulate :return: The encapsulated method '''

Static methods have no implicit parameters. To declare a static method, the conventional approach is:

class C: @staticmethod def fn(arg1, arg2): pass

Example:

class Cat: @staticmethod def speak(): print('Meow Meow Meow') # Call via the class Cat.speak() # Call via an instance cat = Cat() cat.speak()

>>> Establishing WebAssembly Runtime.

>>> Standby.

Powered by Shift.

Created in 6/9/2025

Updated in 6/9/2025